/**
 */
package org.mro.grib.model.files.secondEdition.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.mro.grib.model.files.secondEdition.GRIBFile;
import org.mro.grib.model.files.secondEdition.Message;
import org.mro.grib.model.files.secondEdition.SecondEditionPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>GRIB File</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.impl.GRIBFileImpl#getGribFile <em>Grib File</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.impl.GRIBFileImpl#getMessage <em>Message</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GRIBFileImpl extends EObjectImpl implements GRIBFile {
	/**
	 * The default value of the '{@link #getGribFile() <em>Grib File</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGribFile()
	 * @generated
	 * @ordered
	 */
	protected static final String GRIB_FILE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getGribFile() <em>Grib File</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGribFile()
	 * @generated
	 * @ordered
	 */
	protected String gribFile = GRIB_FILE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getMessage() <em>Message</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMessage()
	 * @generated
	 * @ordered
	 */
	protected EList<Message> message;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GRIBFileImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SecondEditionPackage.Literals.GRIB_FILE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getGribFile() {
		return gribFile;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGribFile(String newGribFile) {
		String oldGribFile = gribFile;
		gribFile = newGribFile;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SecondEditionPackage.GRIB_FILE__GRIB_FILE, oldGribFile, gribFile));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Message> getMessage() {
		if (message == null) {
			message = new EObjectContainmentEList<Message>(Message.class, this, SecondEditionPackage.GRIB_FILE__MESSAGE);
		}
		return message;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SecondEditionPackage.GRIB_FILE__MESSAGE:
				return ((InternalEList<?>)getMessage()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SecondEditionPackage.GRIB_FILE__GRIB_FILE:
				return getGribFile();
			case SecondEditionPackage.GRIB_FILE__MESSAGE:
				return getMessage();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SecondEditionPackage.GRIB_FILE__GRIB_FILE:
				setGribFile((String)newValue);
				return;
			case SecondEditionPackage.GRIB_FILE__MESSAGE:
				getMessage().clear();
				getMessage().addAll((Collection<? extends Message>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SecondEditionPackage.GRIB_FILE__GRIB_FILE:
				setGribFile(GRIB_FILE_EDEFAULT);
				return;
			case SecondEditionPackage.GRIB_FILE__MESSAGE:
				getMessage().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SecondEditionPackage.GRIB_FILE__GRIB_FILE:
				return GRIB_FILE_EDEFAULT == null ? gribFile != null : !GRIB_FILE_EDEFAULT.equals(gribFile);
			case SecondEditionPackage.GRIB_FILE__MESSAGE:
				return message != null && !message.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (gribFile: "); //$NON-NLS-1$
		result.append(gribFile);
		result.append(')');
		return result.toString();
	}

} //GRIBFileImpl
